/**
 * 仓库
 *
 * @author sxf
 * @email sxf02615@163.com
 * @date 2025/1/15
 */
package com.sxf.crm.repository;


import com.sxf.crm.entity.ClueFollowUp;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ClueFollowUpRepository extends JpaRepository<ClueFollowUp, Long> {
    
    List<ClueFollowUp> findByClueIdOrderByFollowUpTimeDesc(Long clueId);
    
    List<ClueFollowUp> findByUserId(Long userId);
    
    @Query("SELECT cf FROM ClueFollowUp cf WHERE cf.remind = true AND cf.remindTime <= :now")
    List<ClueFollowUp> findRemindersToSend(@Param("now") LocalDateTime now);
    
    void deleteByClueId(Long clueId);
} 